#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time: 2022/9/16 17:02
# @Author: 张涛
# @Email: xxx@gmail.com
# @File：bjsj_opt_poge.py


"""
编辑商机页面
"""

from selenium.webdriver.common.by import By
from pages.base_page import BasePage
from time import sleep
class Editor(BasePage):
    djxjkh_locator = (By.ID,'customer_name')  #定位客户
    xzkh_locator = (By.CSS_SELECTOR,'#datas > tr:nth-child(1) > td:nth-child(1) > input[type=radio]:nth-child(1)') #选择客户
    djqj_locator = (By.XPATH,'/html/body/div[8]/div[3]/div/button[1]/span') #选择确定
    dwsjm_locator = (By.CSS_SELECTOR,'#name') #定位商机名
    yjcjj_locator = (By.ID,'estimate_price') #预计成交价
    bcbj_locator = (By.XPATH,'/html/body/div[5]/div[2]/div/form/table/tfoot/tr/td/input[1]') #保存编辑

    def xzkh_element(self):
        '''选择客户'''
        self.driver.find_element(*self.djxjkh_locator).click()
        sleep(2)
        self.driver.find_element(*self.xzkh_locator).click()
        self.driver.find_element(*self.djqj_locator).click()

    def txx_a_element(self,sjm):
        '''填写客户质料'''
        self.driver.find_element(*self.dwsjm_locator).clear()
        self.driver.switch_to.alert.accept()  # 提示弹框选择确定
        self.driver.find_element(*self.dwsjm_locator).send_keys(sjm)

    def txx_b_element(self,yjcjj):
        self.driver.find_element(*self.yjcjj_locator).clear()
        self.driver.find_element(*self.yjcjj_locator).send_keys(yjcjj)

    def txx_c_element(self):
        self.driver.find_element(*self.bcbj_locator).click()
